package org.softmed.neodatis.util.trigger;

import java.util.ArrayList;
import java.util.List;

import org.neodatis.odb.ODB;
import org.softmed.neodatis.util.FakeODB;
import org.softmed.neodatis.util.id.GenerateIDTrigger;

public class TriggerEnvironment {

	List<CloneableInsertTrigger> inserts = new ArrayList<CloneableInsertTrigger>();

	public synchronized ODB setup(ODB odb) {

		// remove this once the Trigger mechanism is working properly...
		CloneableInsertTrigger insertTrigger = null;
		if (inserts.size() > 0)
			insertTrigger = inserts.get(0);

		FakeODB fake = null;
		if (insertTrigger != null)
			fake = new FakeODB(odb, (GenerateIDTrigger) insertTrigger);

		if (fake != null)
			return fake;

		return odb;

	}

	public List<CloneableInsertTrigger> getInserts() {
		return inserts;
	}

}
